Skip to content

feat: project-scoped agent directory — multiple engineers across projects - #592

Merged
namastex888 merged 2 commits into
devfrom
fix/project-scope
Mar 16, 2026
Merged

namastex888 merged 2 commits into
devfrom
fix/project-scope

Conversation

@namastex888

Copy link
Copy Markdown
Contributor

Summary

Closes #578. Agent directory is now project-scoped. genie dir add engineer --dir /path writes to <repo>/.genie/agents.json by default. Resolution: project → global → built-in.

Changes

  • add/rm/edit default to project scope, --global for global
  • resolve(): project .genie/agents.json → global ~/.genie/agent-directory.json → built-in
  • ls shows SCOPE column (project/global/built-in)
  • Same name can be registered in different projects without conflict

Agent directory now defaults to project scope (<repo>/.genie/agents.json)
with fallback to global (~/.genie/agent-directory.json) then built-ins.

- add/rm/edit default to project scope, accept { global: true } option
- resolve() checks project → global → built-in roles → built-in council
- ls() returns entries from all scopes with scope label
- dir CLI commands accept --global flag
- dir ls shows SCOPE column

Closes #578
@coderabbitai

coderabbitai Bot commented Mar 16, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b6a234b6-db4c-4664-93ce-395fa7dded1f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/project-scope
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant architectural change to the agent directory by implementing project-scoped agent management. This allows developers to define and manage agents relevant to a specific codebase, alongside existing global and built-in agents. The change provides greater flexibility and organization for agent configurations, ensuring that agent definitions can be tailored to individual project needs while still allowing for globally accessible agents. The resolution hierarchy ensures that project-specific configurations take precedence, offering a clear and predictable agent lookup mechanism.

Highlights

  • Project-Scoped Agent Directory: The agent directory functionality has been enhanced to support project-specific agent registrations, defaulting operations like add, rm, and edit to the project scope.
  • Global Scope Option: A new --global option has been introduced for add, rm, and edit commands, allowing users to manage agents in a global directory located at ~/.genie/agent-directory.json.
  • Agent Resolution Order: The agent resolution logic now follows a hierarchical order: project-scoped agents are checked first, then global agents, followed by built-in roles, and finally built-in council members. Project entries will shadow global entries with the same name.
  • Enhanced Listing Command: The ls command now displays a 'SCOPE' column, indicating whether an agent is registered at the project, global, or built-in level, providing clearer visibility into agent origins.
  • Duplicate Agent Names Across Scopes: It is now possible to register agents with the same name in different scopes (e.g., a 'developer' agent in a project and a different 'developer' agent globally) without conflict, with project-scoped agents taking precedence during resolution.
Changelog
  • src/lib/agent-directory.test.ts
    • Updated test setup to include separate temporary directories for global and project scopes, using GENIE_HOME and GENIE_PROJECT_ROOT environment variables.
    • Added new tests for add functionality to verify persistence in project scope by default and global scope with the --global option, and to confirm that project entries do not appear in global scope and vice-versa.
    • Modified tests for rm to cover removal from both project and global scopes.
    • Introduced new tests for resolve to confirm resolution order (project shadowing global) and correct retrieval from global scope.
    • Expanded ls tests to verify listing of project entries, global entries, and combined listings with scope labels, including a test for project entries shadowing global entries in the list.
    • Added a test for edit functionality to ensure global entries can be edited using the --global option.
    • Included a new test for getProjectRoot to confirm it respects the GENIE_PROJECT_ROOT environment variable.
  • src/lib/agent-directory.ts
    • Updated documentation comments to reflect the new project and global directory storage paths and the revised resolution order.
    • Added execSync import for executing shell commands.
    • Introduced new types: DirectoryScope, ScopedDirectoryEntry, and ScopeOptions to support scope-aware operations and data structures.
    • Implemented getProjectRoot() function to determine the project's root directory using git rev-parse or falling back to process.cwd(), respecting GENIE_PROJECT_ROOT environment variable.
    • Added getProjectDirectoryPath() and getTargetPath() functions to dynamically determine the correct directory file path based on scope.
    • Refactored internal functions loadDirectory, saveDirectory, and withDirectory to loadDirectoryFrom, saveDirectoryTo, and withDirectoryAt respectively, allowing them to operate on a specified file path.
    • Modified add() function to accept ScopeOptions and use getTargetPath() to persist agents to the correct scope, defaulting to project.
    • Updated rm() function to accept ScopeOptions and remove agents from the specified scope.
    • Revised resolve() function to implement the new resolution order: project -> global -> built-in roles -> built-in council.
    • Changed ls() function to return ScopedDirectoryEntry[], aggregating entries from both project and global scopes, with project entries shadowing global ones of the same name, and adding a scope property to each entry.
    • Modified get() function to accept ScopeOptions and retrieve an agent from the specified scope.
    • Updated edit() function to accept ScopeOptions and apply updates to an agent in the specified scope.
  • src/term-commands/dir.ts
    • Added a --global option to the dir add command to allow registering agents in the global directory.
    • Modified the dir add action to pass the global option to the directory.add function and updated the success message to indicate the scope.
    • Added a --global option to the dir rm command to allow removing agents from the global directory.
    • Updated the dir rm action to pass the global option to the directory.rm function and adjusted the success message to specify the scope.
    • Added a --global option to the dir edit command to allow editing agents in the global directory.
    • Modified the handleEdit function to pass the global option to the directory.edit function and updated the success message to specify the scope.
    • Updated listEntriesJson and printRegisteredTable functions to handle ScopedDirectoryEntry and display the 'SCOPE' column in the table output.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@namastex888
namastex888 merged commit 6c66923 into dev Mar 16, 2026
4 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83fdf8e898

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +91 to +92
function getProjectDirectoryPath(): string {
return join(getProjectRoot(), '.genie', 'agents.json');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use shared repo .genie path for project-scoped directory

getProjectDirectoryPath() now hardcodes <git toplevel>/.genie/agents.json, but in git worktrees git rev-parse --show-toplevel points at the worktree root, not the main repo, so directory entries written in the main project become invisible when commands run inside a worktree. This breaks project-scoped resolution (resolve, ls, and auto-spawn checks that call resolve) for normal worktree-based flows, even though the codebase already has shared-worktree .genie handling via getRepoGenieDir() in src/lib/genie-dir.ts.

Useful? React with 👍 / 👎.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces project-scoped agent directories, a significant enhancement that allows engineers to manage agents on a per-project basis. The changes are well-structured, with a clear separation between project-level (.genie/agents.json) and global (~/.genie/agent-directory.json) configurations. The resolution logic correctly prioritizes project-scoped agents over global ones, and global over built-in ones. The CLI commands (add, rm, edit, ls) have been updated with a --global flag to manage agents in different scopes, and the ls command now helpfully displays the scope of each agent. The test suite has been thoroughly updated to cover these new features, including shadowing and scope-specific operations. I have one minor suggestion to improve code clarity.

export function getProjectRoot(): string {
if (process.env.GENIE_PROJECT_ROOT) return process.env.GENIE_PROJECT_ROOT;
try {
return execSync('git rev-parse --show-toplevel', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For clarity and to be more explicit about the intent, you can use 'ignore' for stdin and stderr in the stdio options. This makes it clearer that you are intentionally ignoring these streams rather than just piping them to be discarded.

Suggested change
return execSync('git rev-parse --show-toplevel', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
return execSync('git rev-parse --show-toplevel', { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant